/* GUI CONVERTED from rescrp2a.i (converter v1.75) Sat Aug 12 23:09:10 2000 */
/* rescrp2a.i - REPETITIVE                                                    */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/*F0PN*/ /*V8:ConvertMode=Maintenance                                         */
/*K1Q4*/ /*V8:WebEnabled=No                                                   */
/* REVISION: 7.3               LAST MODIFIED: 10/31/94   BY: WUG *GN77*       */
/* REVISION: 7.3               LAST MODIFIED: 08/29/95   BY: STR *G0VD*       */
/* REVISION: 8.6               LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan */
/* REVISION: 9.1               LAST MODIFIED: 08/12/00   BY: *N0KP* myb        */


/*INCLUDE FILE TO GET THE APPROPRIATE IRO_DET RECORD                          */


          if cost_set_to_use = "1" then do:
             /*USE CUM ORDER STANDARD COST*/
             find iro_det where iro_part = wo_part
             and iro_site = wo_site
             and iro_cost_set = "cumorder"
             and iro_routing = wo_lot
             and iro_op = wr_op
/*G0VD*      no-lock. */
/*G0VD*/     no-lock no-error.
          end.
          else
          if cost_set_to_use = "2" then do:
             /*USE CUM ORDER AVERAGE COST*/
             find iro_det where iro_part = wo_part
             and iro_site = wo_site
             and iro_cost_set = "cumorderavg"
             and iro_routing = wo_lot
             and iro_op = wr_op
             exclusive-lock no-error.

             if not available iro_det then do:
                create iro_det.

                assign
                iro_part = wo_part
                iro_site = wo_site
                iro_cost_set = "cumorderavg"
                iro_routing = wo_lot
                iro_op = wr_op
                .
             end.

             if wr_qty_cumproc <> 0 then do:
                /*UPDATE COSTS*/
                iro_lbr_ll = wr_lbr_ll_act / wr_qty_cumproc.
                iro_bdn_ll = wr_bdn_ll_act / wr_qty_cumproc.
                iro_sub_ll = wr_sub_ll_act / wr_qty_cumproc.
                iro_mtl_ll = wr_mtl_ll_act / wr_qty_cumproc.

                iro_lbr_tl = wr_lbr_act / wr_qty_cumproc.
                iro_bdn_tl = wr_bdn_act / wr_qty_cumproc.
                iro_sub_tl = wr_sub_act / wr_qty_cumproc.
                iro_mtl_tl = wr_mtl_act / wr_qty_cumproc.
             end.
             else do:
                iro_lbr_ll = 0.
                iro_bdn_ll = 0.
                iro_sub_ll = 0.
                iro_mtl_ll = 0.

                iro_lbr_tl = 0.
                iro_bdn_tl = 0.
                iro_sub_tl = 0.
                iro_mtl_tl = 0.
             end.

             iro_cost_tot =
             iro_lbr_ll + iro_bdn_ll + iro_sub_ll + iro_mtl_ll +
             iro_lbr_tl + iro_bdn_tl + iro_sub_tl + iro_mtl_tl.
          end.
          else do:
             /*USE G/L COST*/
             routing = wo_part.
             bom_code = wo_part.
             if wo_routing > "" then routing = wo_routing.
             if wo_bom_code > "" then bom_code = wo_bom_code.

             {gprun.i ""csavg01.p"" "(input wo_part, input wo_site,
             output gl_cost_set, output gl_cost_mthd,
             output cur_cost_set, output cur_cost_mthd)"}
/*GUI*/ if global-beam-me-up then undo, leave.



             find iro_det
             where iro_part = bom_code
             and iro_site = wo_site
             and iro_cost_set = gl_cost_set
             and iro_routing = routing
             and iro_op = wr_op
             no-lock no-error.

             if not available iro_det then do:
                ord_qty = 1.

                if pt_ord_qty <> 0 then ord_qty = pt_ord_qty.

                find ptp_det where ptp_part = wo_part and ptp_site = wo_site
                no-lock no-error.

                if available ptp_det then do:
             if ptp_ord_qty <> 0 then ord_qty = ptp_ord_qty.
                end.

                {gprun.i ""rwroru1a.p""
                "(wo_site,gl_cost_set,routing,bom_code,ord_qty,today,yes)"}
/*GUI*/ if global-beam-me-up then undo, leave.


                find iro_det
                where iro_part = bom_code
                and iro_site = wo_site
                and iro_cost_set = gl_cost_set
                and iro_routing = routing
                and iro_op = wr_op
/*G0VD*         no-lock. */
/*G0VD*/        no-lock no-error.
             end.
          end.
